package com.gary.springcloud.service;

import com.gary.springcloud.entity.Order;
import com.gary.springcloud.enums.StatusEnum;
import com.gary.springcloud.mapper.OrderMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;

/**
 * @author peng_rui
 * @date 2023/2/13
 */
@Slf4j
@Service
public class OrderService {
    @Resource
    private OrderMapper orderMapper;

    /**
     * 新增
     * @param order
     * @return
     */
    public Integer add(Order order) {
        order.setStatus(StatusEnum.ADDING.getCode());
        return orderMapper.insertSelective(order);
    }

    public Integer update(Order order) {
        order.setStatus(StatusEnum.SUCCESS.getCode());
        return orderMapper.updateByPrimaryKey(order);
    }
}
